﻿namespace net.zxteam.ZXLexer
{
	using System;
	using System.Collections.Generic;

	public sealed class StringParsingSource : ParsingSourceBase
	{
		private readonly string _text;
		private int _offset = -1;

		public StringParsingSource(string text)
		{
			if (text == null) throw new ArgumentNullException();

			this._text = text;
		}


		public override bool MoveNext()
		{
			if (this._offset < this._text.Length)
			{
				++this._offset;

				if (this._offset < this._text.Length)
				{
					return true;
				}
			}

			return false;

		}

		public override char Current
		{
			get
			{
				if (this._offset >= 0 && this._offset < this._text.Length)
				{
					return this._text[this._offset];
				}

				throw new InvalidOperationException();
			}
		}

		public override void Reset() { this._offset = -1; }

		public override int Position { get { return this._offset; } }
	}
}
